class Person:
    Count = 0
    def __init__(self, name, age):
        Person.Count += 1
        self.name = name
        self.__age = age

p = Person("peter", 25)
p1 = Person("john", 20)

print Person.Count #2
print p.name #peter
# print p.__age #AttributeError: Person instance has no attribute '__age'


f = file("test.txt", "w") # open for writing, the file will be created if the file doesn't exist
f.write("12\nfasfda") # write text to file
f.close()
f = file("test.txt") # if no mode is specified, the default mode is readonly.

while True:
    line = f.readline()
    if len(line) == 0:  # zero length indicates the EOF of the file
        break
    print line
f.close()


try:
    print 1/0
except ZeroDivisionError, e:
    print e
except:
    print "error or exception occurred."

try:
    f = file("test.txt")
    while True:
        line = f.readline()
        if len(line) == 0:
            break
        print line,
finally:
    f.close()
    print "Cleaning up..."
